fix default image format in gtk4 savefig dialog #27716
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
When I try to save a figure using the gtk4 file chooser the default format is
PGF code for LaTeX
, but it should be "png" because I setrcParams["savefig.format"] = 'png'
. The default file extension is still.png
, confusingly. This only started happening after I recently upgraded my system to gtk4.Looking at the code, I see an indexing bug when choosing the default format: The previous lines to my diff reorganized the format order so that the default format is the first in the list, therefore to get the default one should use index 0, not the old index before reordering.
PR checklist
I manually tested that the dialog works as expected after this PR. I did not run the unit tests, nor create a unit test, but I can run them if requested. I hope that CI can be enough for such a small change as I haven't set up a dev env for matplotlib.